/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package trialinventory2.to;

/**
 *
 * @author i1
 */
public class ProductTO {

   /**
    * Product
    * Quantity
    * Price
    * Total
    */

    public final String product;
    public final double price;

    private double quantity;

    public ProductTO(String product, double price) {
        this.product = product;
        this.price = price;
    }

    public double getTotal() {
       return price * quantity;
    }

    public double getQuantity() {
        return quantity;
    }

    public void setQuantity(double quantity) {
        this.quantity = quantity;
    }

    @Override
    public boolean equals(Object o ) {
        if( o == null ) return false;
        if( !(o instanceof ProductTO )) return false;

        ProductTO io = (ProductTO) o;
        boolean eq1 =  io.product.equals(this.product);
        boolean eq2 = (io.price == this.price);
        
        return (eq1 && eq2);

    }

    @Override
    public String toString() {
        return "ProductTO{" + "product=" + product + "price=" +
                price + "quantity=" + quantity + "total=" + getTotal() + '}';
    }

    

//    public static void main(String[] args) {
//
//        ProductTO to = new ProductTO("elorde", 5);
//        to.setQuantity(10);
//        System.out.println(to);
//    }
    
}
